package com.lxmes.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.business.domain.YqReg;
import com.lxmes.business.service.IYqRegService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 园区系统Controller
 * 
 * @author ruoyi
 * @date 2022-11-25
 */
@RestController
@RequestMapping("/business/reg")
public class YqRegController extends BaseController
{
    @Autowired
    private IYqRegService yqRegService;

    /**
     * 查询园区系统列表
     */
    @PreAuthorize("@ss.hasPermi('business:reg:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqReg yqReg)
    {
        startPage();
        List<YqReg> list = yqRegService.selectYqRegList(yqReg);
        return getDataTable(list);
    }

    /**
     * 导出园区系统列表
     */
    @PreAuthorize("@ss.hasPermi('business:reg:export')")
    @Log(title = "园区系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqReg yqReg)
    {
        List<YqReg> list = yqRegService.selectYqRegList(yqReg);
        ExcelUtil<YqReg> util = new ExcelUtil<YqReg>(YqReg.class);
        util.exportExcel(response, list, "园区系统数据");
    }

    /**
     * 获取园区系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:reg:query')")
    @GetMapping(value = "/{uuid}")
    public AjaxResult getInfo(@PathVariable("uuid") String uuid)
    {
        return AjaxResult.success(yqRegService.selectYqRegByUuid(uuid));
    }

    /**
     * 新增园区系统
     */
    @PreAuthorize("@ss.hasPermi('business:reg:add')")
    @Log(title = "园区系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqReg yqReg)
    {
        return toAjax(yqRegService.insertYqReg(yqReg));
    }

    /**
     * 修改园区系统
     */
    @PreAuthorize("@ss.hasPermi('business:reg:edit')")
    @Log(title = "园区系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqReg yqReg)
    {
        return toAjax(yqRegService.updateYqReg(yqReg));
    }

    /**
     * 删除园区系统
     */
    @PreAuthorize("@ss.hasPermi('business:reg:remove')")
    @Log(title = "园区系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uuids}")
    public AjaxResult remove(@PathVariable String[] uuids)
    {
        return toAjax(yqRegService.deleteYqRegByUuids(uuids));
    }
}
